.class public Lcom/teewoo/app/bus/db/MySqliteHelper;
.super Landroid/database/sqlite/SQLiteOpenHelper;
.source "MySqliteHelper.java"


# static fields
.field private static final DATABASE_FILENAME:Ljava/lang/String; = "offset.db"

.field private static final DATABASE_PATH:Ljava/lang/String; = "/data/data/com.teewoo.app.bus/databases"

.field private static VERSION:I = 0x0

.field private static final dbName:Ljava/lang/String; = "/data/data/com.teewoo.app.bus/databases/offset.db"


# instance fields
.field databaseFileName:Ljava/lang/String;

.field myContext:Landroid/content/Context;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 29
    const/4 v0, 0x1

    sput v0, Lcom/teewoo/app/bus/db/MySqliteHelper;->VERSION:I

    .line 24
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;)V
    .locals 3
    .parameter "context"

    .prologue
    .line 34
    const-string v0, "/data/data/com.teewoo.app.bus/databases/offset.db"

    const/4 v1, 0x0

    sget v2, Lcom/teewoo/app/bus/db/MySqliteHelper;->VERSION:I

    invoke-direct {p0, p1, v0, v1, v2}, Landroid/database/sqlite/SQLiteOpenHelper;-><init>(Landroid/content/Context;Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;I)V

    .line 30
    const-string v0, "/data/data/com.teewoo.app.bus/databases/offset.db"

    iput-object v0, p0, Lcom/teewoo/app/bus/db/MySqliteHelper;->databaseFileName:Ljava/lang/String;

    .line 35
    iput-object p1, p0, Lcom/teewoo/app/bus/db/MySqliteHelper;->myContext:Landroid/content/Context;

    .line 36
    invoke-direct {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->checkDBExists()V

    .line 37
    return-void
.end method

.method private checkDBExists()V
    .locals 8

    .prologue
    .line 66
    new-instance v2, Ljava/io/File;

    const-string v6, "/data/data/com.teewoo.app.bus/databases"

    invoke-direct {v2, v6}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 67
    .local v2, dir:Ljava/io/File;
    invoke-virtual {v2}, Ljava/io/File;->exists()Z

    move-result v6

    if-nez v6, :cond_0

    .line 68
    invoke-virtual {v2}, Ljava/io/File;->mkdir()Z

    .line 71
    :cond_0
    new-instance v6, Ljava/io/File;

    iget-object v7, p0, Lcom/teewoo/app/bus/db/MySqliteHelper;->databaseFileName:Ljava/lang/String;

    invoke-direct {v6, v7}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v6}, Ljava/io/File;->exists()Z

    move-result v6

    if-nez v6, :cond_1

    .line 74
    :try_start_0
    iget-object v6, p0, Lcom/teewoo/app/bus/db/MySqliteHelper;->myContext:Landroid/content/Context;

    invoke-virtual {v6}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v6

    .line 75
    const v7, 0x7f050002

    .line 74
    invoke-virtual {v6, v7}, Landroid/content/res/Resources;->openRawResource(I)Ljava/io/InputStream;

    move-result-object v5

    .line 76
    .local v5, is:Ljava/io/InputStream;
    new-instance v4, Ljava/io/FileOutputStream;

    iget-object v6, p0, Lcom/teewoo/app/bus/db/MySqliteHelper;->databaseFileName:Ljava/lang/String;

    invoke-direct {v4, v6}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V

    .line 78
    .local v4, fos:Ljava/io/FileOutputStream;
    const/16 v6, 0x2000

    new-array v0, v6, [B

    .line 79
    .local v0, buffer:[B
    const/4 v1, 0x0

    .line 80
    .local v1, count:I
    :goto_0
    invoke-virtual {v5, v0}, Ljava/io/InputStream;->read([B)I

    move-result v1

    if-gtz v1, :cond_2

    .line 84
    invoke-virtual {v4}, Ljava/io/FileOutputStream;->close()V

    .line 85
    invoke-virtual {v5}, Ljava/io/InputStream;->close()V

    .line 94
    .end local v0           #buffer:[B
    .end local v1           #count:I
    .end local v4           #fos:Ljava/io/FileOutputStream;
    .end local v5           #is:Ljava/io/InputStream;
    :cond_1
    :goto_1
    return-void

    .line 81
    .restart local v0       #buffer:[B
    .restart local v1       #count:I
    .restart local v4       #fos:Ljava/io/FileOutputStream;
    .restart local v5       #is:Ljava/io/InputStream;
    :cond_2
    const/4 v6, 0x0

    invoke-virtual {v4, v0, v6, v1}, Ljava/io/FileOutputStream;->write([BII)V
    :try_end_0
    .catch Landroid/content/res/Resources$NotFoundException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/FileNotFoundException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_2

    goto :goto_0

    .line 86
    .end local v0           #buffer:[B
    .end local v1           #count:I
    .end local v4           #fos:Ljava/io/FileOutputStream;
    .end local v5           #is:Ljava/io/InputStream;
    :catch_0
    move-exception v6

    move-object v3, v6

    .line 87
    .local v3, e:Landroid/content/res/Resources$NotFoundException;
    invoke-virtual {v3}, Landroid/content/res/Resources$NotFoundException;->printStackTrace()V

    goto :goto_1

    .line 88
    .end local v3           #e:Landroid/content/res/Resources$NotFoundException;
    :catch_1
    move-exception v6

    move-object v3, v6

    .line 89
    .local v3, e:Ljava/io/FileNotFoundException;
    invoke-virtual {v3}, Ljava/io/FileNotFoundException;->printStackTrace()V

    goto :goto_1

    .line 90
    .end local v3           #e:Ljava/io/FileNotFoundException;
    :catch_2
    move-exception v6

    move-object v3, v6

    .line 91
    .local v3, e:Ljava/io/IOException;
    invoke-virtual {v3}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_1
.end method


# virtual methods
.method public adjustGoogleMapOffset(Lcom/teewoo/app/bus/model/Station;)Lcom/teewoo/app/bus/model/Station;
    .locals 14
    .parameter "station"

    .prologue
    const/4 v13, 0x7

    const/4 v12, 0x6

    const-wide v10, 0x3f726e978d4fdf3bL

    const-wide v8, 0x3f647ae147ae147bL

    const-wide/16 v6, 0x0

    .line 185
    invoke-virtual {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 186
    .local v1, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v2, "select * from map_offset where station = ? "

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/String;

    const/4 v4, 0x0

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/Station;->getName()Ljava/lang/String;

    move-result-object v5

    aput-object v5, v3, v4

    invoke-virtual {v1, v2, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 187
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v2

    if-eqz v2, :cond_3

    .line 188
    invoke-interface {v0, v12}, Landroid/database/Cursor;->getDouble(I)D

    move-result-wide v2

    cmpl-double v2, v2, v6

    if-eqz v2, :cond_0

    invoke-interface {v0, v13}, Landroid/database/Cursor;->getDouble(I)D

    move-result-wide v2

    cmpl-double v2, v2, v6

    if-nez v2, :cond_2

    .line 189
    :cond_0
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/Station;->getLat()D

    move-result-wide v2

    sub-double/2addr v2, v8

    invoke-virtual {p1, v2, v3}, Lcom/teewoo/app/bus/model/Station;->setLat(D)V

    .line 190
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/Station;->getLon()D

    move-result-wide v2

    add-double/2addr v2, v10

    invoke-virtual {p1, v2, v3}, Lcom/teewoo/app/bus/model/Station;->setLon(D)V

    .line 199
    :goto_0
    if-eqz v0, :cond_1

    .line 200
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 201
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 203
    :cond_1
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 204
    return-object p1

    .line 192
    :cond_2
    invoke-interface {v0, v12}, Landroid/database/Cursor;->getDouble(I)D

    move-result-wide v2

    invoke-virtual {p1, v2, v3}, Lcom/teewoo/app/bus/model/Station;->setLat(D)V

    .line 193
    invoke-interface {v0, v13}, Landroid/database/Cursor;->getDouble(I)D

    move-result-wide v2

    invoke-virtual {p1, v2, v3}, Lcom/teewoo/app/bus/model/Station;->setLon(D)V

    goto :goto_0

    .line 196
    :cond_3
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/Station;->getLat()D

    move-result-wide v2

    sub-double/2addr v2, v8

    invoke-virtual {p1, v2, v3}, Lcom/teewoo/app/bus/model/Station;->setLat(D)V

    .line 197
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/Station;->getLon()D

    move-result-wide v2

    add-double/2addr v2, v10

    invoke-virtual {p1, v2, v3}, Lcom/teewoo/app/bus/model/Station;->setLon(D)V

    goto :goto_0
.end method

.method public findAllProvince()Ljava/util/List;
    .locals 6
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .prologue
    .line 123
    new-instance v3, Ljava/util/ArrayList;

    invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V

    .line 124
    .local v3, provs:Ljava/util/List;,"Ljava/util/List<Ljava/lang/String;>;"
    invoke-virtual {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 125
    .local v1, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v4, "SELECT DISTINCT province_name FROM cities"

    .line 126
    .local v4, sql:Ljava/lang/String;
    const/4 v5, 0x0

    invoke-virtual {v1, v4, v5}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 127
    .local v0, cursor:Landroid/database/Cursor;
    :goto_0
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v5

    if-nez v5, :cond_1

    .line 132
    if-eqz v0, :cond_0

    .line 133
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 134
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 136
    :cond_0
    return-object v3

    .line 129
    :cond_1
    const-string v5, "province_name"

    invoke-interface {v0, v5}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v5

    .line 128
    invoke-interface {v0, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    .line 130
    .local v2, prov:Ljava/lang/String;
    invoke-interface {v3, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0
.end method

.method public findCitiesByProv(Ljava/lang/String;)Ljava/util/List;
    .locals 12
    .parameter "provName"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/List",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/UnsupportedEncodingException;
        }
    .end annotation

    .prologue
    const/4 v4, 0x1

    const/4 v11, 0x0

    const/4 v5, 0x0

    .line 143
    new-instance v8, Ljava/util/ArrayList;

    invoke-direct {v8}, Ljava/util/ArrayList;-><init>()V

    .line 144
    .local v8, cities:Ljava/util/List;,"Ljava/util/List<Ljava/lang/String;>;"
    invoke-virtual {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 145
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "cities"

    new-array v2, v4, [Ljava/lang/String;

    const-string v3, "city_name"

    aput-object v3, v2, v11

    .line 146
    const-string v3, "province_name=?"

    .line 147
    new-array v4, v4, [Ljava/lang/String;

    new-instance v6, Ljava/lang/String;

    invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B

    move-result-object v7

    const-string v10, "UTF-8"

    invoke-direct {v6, v7, v10}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    aput-object v6, v4, v11

    move-object v6, v5

    move-object v7, v5

    .line 145
    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v9

    .line 149
    .local v9, cursor:Landroid/database/Cursor;
    :goto_0
    invoke-interface {v9}, Landroid/database/Cursor;->moveToNext()Z

    move-result v1

    if-nez v1, :cond_1

    .line 152
    if-eqz v9, :cond_0

    .line 153
    invoke-interface {v9}, Landroid/database/Cursor;->close()V

    .line 154
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 156
    :cond_0
    return-object v8

    .line 150
    :cond_1
    const-string v1, "city_name"

    invoke-interface {v9, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v1

    invoke-interface {v9, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-interface {v8, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0
.end method

.method public findCityByName(Ljava/lang/String;)Lcom/teewoo/app/bus/model/weather/City;
    .locals 12
    .parameter "cityName"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/UnsupportedEncodingException;
        }
    .end annotation

    .prologue
    const/4 v4, 0x1

    const/4 v11, 0x0

    const/4 v5, 0x0

    .line 100
    const/4 v8, 0x0

    .line 101
    .local v8, city:Lcom/teewoo/app/bus/model/weather/City;
    invoke-virtual {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 102
    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "cities"

    const/4 v2, 0x2

    new-array v2, v2, [Ljava/lang/String;

    const-string v3, "longitude"

    aput-object v3, v2, v11

    .line 103
    const-string v3, "latitude"

    aput-object v3, v2, v4

    const-string v3, "city_name=?"

    .line 104
    new-array v4, v4, [Ljava/lang/String;

    new-instance v6, Ljava/lang/String;

    invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B

    move-result-object v7

    const-string v10, "UTF-8"

    invoke-direct {v6, v7, v10}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    aput-object v6, v4, v11

    move-object v6, v5

    move-object v7, v5

    .line 102
    invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v9

    .line 106
    .local v9, cursor:Landroid/database/Cursor;
    invoke-interface {v9}, Landroid/database/Cursor;->moveToNext()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 107
    new-instance v8, Lcom/teewoo/app/bus/model/weather/City;

    .end local v8           #city:Lcom/teewoo/app/bus/model/weather/City;
    invoke-direct {v8}, Lcom/teewoo/app/bus/model/weather/City;-><init>()V

    .line 108
    .restart local v8       #city:Lcom/teewoo/app/bus/model/weather/City;
    invoke-virtual {v8, p1}, Lcom/teewoo/app/bus/model/weather/City;->setName(Ljava/lang/String;)V

    .line 109
    const-string v1, "latitude"

    invoke-interface {v9, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v1

    invoke-interface {v9, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v8, v1}, Lcom/teewoo/app/bus/model/weather/City;->setLat(Ljava/lang/String;)V

    .line 110
    const-string v1, "longitude"

    invoke-interface {v9, v1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v1

    invoke-interface {v9, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v8, v1}, Lcom/teewoo/app/bus/model/weather/City;->setLon(Ljava/lang/String;)V

    .line 113
    :cond_0
    if-eqz v9, :cond_1

    .line 114
    invoke-interface {v9}, Landroid/database/Cursor;->close()V

    .line 115
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 117
    :cond_1
    return-object v8
.end method

.method public getAllBusLines()[Ljava/lang/String;
    .locals 10

    .prologue
    .line 208
    new-instance v3, Ljava/util/ArrayList;

    invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V

    .line 209
    .local v3, list:Ljava/util/List;,"Ljava/util/List<Lcom/teewoo/app/bus/model/autocomplete/AutoItem;>;"
    const-string v4, "select _id,line_no,line_name,line_abbr from xm_lines"

    .line 210
    .local v4, sql:Ljava/lang/String;
    invoke-virtual {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 211
    .local v1, db:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v6, 0x0

    new-array v6, v6, [Ljava/lang/String;

    invoke-virtual {v1, v4, v6}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 212
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v6

    if-eqz v6, :cond_1

    .line 214
    :cond_0
    new-instance v6, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;

    const/4 v7, 0x1

    invoke-interface {v0, v7}, Landroid/database/Cursor;->getInt(I)I

    move-result v7

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    const/4 v8, 0x2

    invoke-interface {v0, v8}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v8

    const/4 v9, 0x3

    invoke-interface {v0, v9}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v9

    invoke-direct {v6, v7, v8, v9}, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;-><init>(Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v3, v6}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 215
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v6

    .line 213
    if-nez v6, :cond_0

    .line 217
    :cond_1
    if-eqz v0, :cond_2

    .line 218
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 219
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 221
    :cond_2
    const/4 v5, 0x0

    check-cast v5, [Ljava/lang/String;

    .line 222
    .local v5, str:[Ljava/lang/String;
    invoke-interface {v3}, Ljava/util/List;->size()I

    move-result v6

    if-lez v6, :cond_3

    .line 223
    invoke-interface {v3}, Ljava/util/List;->size()I

    move-result v6

    new-array v5, v6, [Ljava/lang/String;

    .line 224
    const/4 v2, 0x0

    .end local p0
    .local v2, i:I
    :goto_0
    invoke-interface {v3}, Ljava/util/List;->size()I

    move-result v6

    if-lt v2, v6, :cond_4

    .line 228
    .end local v2           #i:I
    :cond_3
    return-object v5

    .line 225
    .restart local v2       #i:I
    :cond_4
    invoke-interface {v3, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object p0

    check-cast p0, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;

    invoke-virtual {p0}, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;->getItemName()Ljava/lang/String;

    move-result-object v6

    aput-object v6, v5, v2

    .line 224
    add-int/lit8 v2, v2, 0x1

    goto :goto_0
.end method

.method public getAllBusStations()Ljava/util/List;
    .locals 8
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Lcom/teewoo/app/bus/model/autocomplete/AutoItem;",
            ">;"
        }
    .end annotation

    .prologue
    .line 232
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    .line 233
    .local v2, list:Ljava/util/List;,"Ljava/util/List<Lcom/teewoo/app/bus/model/autocomplete/AutoItem;>;"
    const-string v3, "select _id,station_no,station_name,station_abbr from xm_stations"

    .line 234
    .local v3, sql:Ljava/lang/String;
    invoke-virtual {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 235
    .local v1, db:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v4, 0x0

    new-array v4, v4, [Ljava/lang/String;

    invoke-virtual {v1, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 236
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v4

    if-eqz v4, :cond_1

    .line 238
    :cond_0
    new-instance v4, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;

    const/4 v5, 0x1

    invoke-interface {v0, v5}, Landroid/database/Cursor;->getInt(I)I

    move-result v5

    invoke-static {v5}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    const/4 v6, 0x2

    invoke-interface {v0, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    const/4 v7, 0x3

    invoke-interface {v0, v7}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v4, v5, v6, v7}, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;-><init>(Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v2, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 239
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v4

    .line 237
    if-nez v4, :cond_0

    .line 241
    :cond_1
    if-eqz v0, :cond_2

    .line 242
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 243
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 245
    :cond_2
    return-object v2
.end method

.method public getCityByLocation(Landroid/location/Location;)Lcom/teewoo/app/bus/model/weather/City;
    .locals 10
    .parameter "loc"

    .prologue
    const-wide v8, 0x412e848000000000L

    .line 162
    const/4 v0, 0x0

    .line 163
    .local v0, city:Lcom/teewoo/app/bus/model/weather/City;
    if-nez p1, :cond_2

    const-string v6, "24486000"

    move-object v3, v6

    .line 164
    .local v3, lat:Ljava/lang/String;
    :goto_0
    if-nez p1, :cond_3

    const-string v6, "118140000"

    move-object v4, v6

    .line 165
    .local v4, lon:Ljava/lang/String;
    :goto_1
    invoke-virtual {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v2

    .line 166
    .local v2, db:Landroid/database/sqlite/SQLiteDatabase;
    const-string v5, "select * from cities where (abs(longitude - ?) * abs(longitude - ?) + abs(latitude - ?) * abs(latitude - ?)) = (select min(abs(longitude - ?) * abs(longitude - ?) + abs(latitude - ?) * abs(latitude - ?)) from cities)"

    .line 168
    .local v5, sql:Ljava/lang/String;
    const/16 v6, 0x8

    new-array v6, v6, [Ljava/lang/String;

    const/4 v7, 0x0

    aput-object v4, v6, v7

    const/4 v7, 0x1

    aput-object v4, v6, v7

    const/4 v7, 0x2

    aput-object v3, v6, v7

    const/4 v7, 0x3

    aput-object v3, v6, v7

    const/4 v7, 0x4

    .line 169
    aput-object v4, v6, v7

    const/4 v7, 0x5

    aput-object v4, v6, v7

    const/4 v7, 0x6

    aput-object v3, v6, v7

    const/4 v7, 0x7

    aput-object v3, v6, v7

    .line 168
    invoke-virtual {v2, v5, v6}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    .line 170
    .local v1, cursor:Landroid/database/Cursor;
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z

    move-result v6

    if-eqz v6, :cond_0

    .line 171
    new-instance v0, Lcom/teewoo/app/bus/model/weather/City;

    .end local v0           #city:Lcom/teewoo/app/bus/model/weather/City;
    invoke-direct {v0}, Lcom/teewoo/app/bus/model/weather/City;-><init>()V

    .line 172
    .restart local v0       #city:Lcom/teewoo/app/bus/model/weather/City;
    const-string v6, "city_name"

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v6

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v0, v6}, Lcom/teewoo/app/bus/model/weather/City;->setName(Ljava/lang/String;)V

    .line 173
    const-string v6, "latitude"

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v6

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v0, v6}, Lcom/teewoo/app/bus/model/weather/City;->setLat(Ljava/lang/String;)V

    .line 174
    const-string v6, "longitude"

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v6

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v0, v6}, Lcom/teewoo/app/bus/model/weather/City;->setLon(Ljava/lang/String;)V

    .line 176
    :cond_0
    if-eqz v1, :cond_1

    .line 177
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    .line 178
    invoke-virtual {v2}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 180
    :cond_1
    return-object v0

    .line 163
    .end local v1           #cursor:Landroid/database/Cursor;
    .end local v2           #db:Landroid/database/sqlite/SQLiteDatabase;
    .end local v3           #lat:Ljava/lang/String;
    .end local v4           #lon:Ljava/lang/String;
    .end local v5           #sql:Ljava/lang/String;
    :cond_2
    invoke-virtual {p1}, Landroid/location/Location;->getLatitude()D

    move-result-wide v6

    mul-double/2addr v6, v8

    invoke-static {v6, v7}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object v6

    move-object v3, v6

    goto :goto_0

    .line 164
    .restart local v3       #lat:Ljava/lang/String;
    :cond_3
    invoke-virtual {p1}, Landroid/location/Location;->getLongitude()D

    move-result-wide v6

    mul-double/2addr v6, v8

    invoke-static {v6, v7}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object v6

    move-object v4, v6

    goto :goto_1
.end method

.method public declared-synchronized getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;
    .locals 4

    .prologue
    const/4 v3, 0x0

    .line 47
    monitor-enter p0

    :try_start_0
    invoke-direct {p0}, Lcom/teewoo/app/bus/db/MySqliteHelper;->checkDBExists()V

    .line 48
    new-instance v1, Ljava/io/File;

    iget-object v2, p0, Lcom/teewoo/app/bus/db/MySqliteHelper;->databaseFileName:Ljava/lang/String;

    invoke-direct {v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 50
    iget-object v1, p0, Lcom/teewoo/app/bus/db/MySqliteHelper;->databaseFileName:Ljava/lang/String;

    const/4 v2, 0x0

    .line 49
    invoke-static {v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->openOrCreateDatabase(Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;)Landroid/database/sqlite/SQLiteDatabase;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result-object v0

    .local v0, db:Landroid/database/sqlite/SQLiteDatabase;
    move-object v1, v0

    .line 53
    .end local v0           #db:Landroid/database/sqlite/SQLiteDatabase;
    :goto_0
    monitor-exit p0

    return-object v1

    :cond_0
    move-object v1, v3

    goto :goto_0

    .line 47
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public listToStrArray(Ljava/util/List;)[Ljava/lang/String;
    .locals 3
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List",
            "<",
            "Lcom/teewoo/app/bus/model/autocomplete/AutoItem;",
            ">;)[",
            "Ljava/lang/String;"
        }
    .end annotation

    .prologue
    .line 249
    .local p1, list:Ljava/util/List;,"Ljava/util/List<Lcom/teewoo/app/bus/model/autocomplete/AutoItem;>;"
    invoke-interface {p1}, Ljava/util/List;->size()I

    move-result v2

    new-array v1, v2, [Ljava/lang/String;

    .line 250
    .local v1, str:[Ljava/lang/String;
    const/4 v0, 0x0

    .end local p0
    .local v0, i:I
    :goto_0
    invoke-interface {p1}, Ljava/util/List;->size()I

    move-result v2

    if-lt v0, v2, :cond_0

    .line 253
    return-object v1

    .line 251
    :cond_0
    invoke-interface {p1, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object p0

    check-cast p0, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;

    invoke-virtual {p0}, Lcom/teewoo/app/bus/model/autocomplete/AutoItem;->getItemName()Ljava/lang/String;

    move-result-object v2

    aput-object v2, v1, v0

    .line 250
    add-int/lit8 v0, v0, 0x1

    goto :goto_0
.end method

.method public onCreate(Landroid/database/sqlite/SQLiteDatabase;)V
    .locals 0
    .parameter "db"

    .prologue
    .line 43
    return-void
.end method

.method public onUpgrade(Landroid/database/sqlite/SQLiteDatabase;II)V
    .locals 0
    .parameter "db"
    .parameter "oldVersion"
    .parameter "newVersion"

    .prologue
    .line 59
    return-void
.end method
